<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>静态评语设置</title>
    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/plugins/layui/css/layui.css" media="all" />

</head>
<body>

<form  class="layui-form layui-form-pane" style="width: 90%;margin-top: 10px;margin-left: 10px;" action="">
    <div class="layui-form-item">
        <a class="layui-btn" href="javascript:fenshuedit();">
            <i class="layui-icon">&#xe608;</i> 添加
        </a>
    </div>
    <input type="hidden" name="assignmentid" value="<{$assignmentid}>">
    <div id="fenshuedit">
        <if condition="$ret eq null">
            <div id="fenshu_1" class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">分数范围</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="number" name="price[fenshu_1][min]" placeholder="分数" autocomplete="off" class="layui-input" value="0">
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="number" name="price[fenshu_1][max]"  placeholder="分数" autocomplete="off" class="layui-input">
                    </div>
                    <!--<div class="layui-input-inline" style="width: 100px;">
                        <button class="layui-btn" onclick="$('#fenshu_1').remove();">
                            <i class="layui-icon">&#xe640;</i> 删除
                        </button>
                    </div>-->
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">评语</label>
                    <div class="layui-input-block">
                        <textarea name="price[fenshu_1][comment]" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <hr>
            </div>
        <else />
            <foreach name="ret" item="v" key="k">
                <div id="fenshu_<{$v.id}>" class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">分数范围</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="number" name="price[fenshu_<{$v.id}>][min]" placeholder="分数" autocomplete="off" class="layui-input" value="<{$v.min}>">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="number" name="price[fenshu_<{$v.id}>][max]"  placeholder="分数" autocomplete="off" class="layui-input" value="<{$v.max}>">
                        </div>
                        <if condition="$tmp_if neq 0">
                        <div class="layui-input-inline" style="width: 100px;">
                            <button class="layui-btn" onclick="$('#fenshu_<{$v.id}>').remove();">
                                <i class="layui-icon">&#xe640;</i> 删除
                            </button>
                        </div>
                        </if>
                        <php>$tmp_if = 1;</php>
                    </div>

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">评语</label>
                        <div class="layui-input-block">
                            <textarea name="price[fenshu_<{$v.id}>][comment]" placeholder="请输入内容" class="layui-textarea"><{$v.comment}></textarea>
                        </div>
                    </div>
                    <hr>
                </div>
            </foreach>
        </if>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


<script src="__PUBLIC__/BeginnerAdmin/plugins/layui/layui.js"></script>
<script type="text/javascript" src="__PUBLIC__/AmazeUI/assets/js/jquery-1.8.0.min.js"></script>

<script>
    layui.use(['form','laydate','layer'], function(){
        var form = layui.form,laydate = layui.laydate,$ = layui.$;
        //监听提交
        form.on('submit(demo)', function(data){
            $.post('Admin_Paper_Comment.html',data.field,function (data) {
                if(data.code == 200){
                    layer.msg('修改成功');
                    setTimeout('settime()', 1500);//延时执行，让人看得更清楚
                }else{
                    layer.alert(data.msg);
                }
            });
            return false;
        });
    });
    function settime() {
        // window.location.href = 'Admin_Topic_NewTopicUI.html?examinationid=<{$examinationid}>';
        var index=parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    function fenshuedit() {
        var myDate = new Date();
        var s_id = "fenshu"+myDate.getHours()+""+myDate.getMinutes()+""+myDate.getSeconds()+""+myDate.getMilliseconds()+""+Math.ceil(Math.random()*100);
        console.log(s_id);
        $("#fenshuedit").append(
            "    <div id=\""+s_id+"\" class=\"layui-form-item\">\n" +
            "        <div class=\"layui-inline\">\n" +
            "            <label class=\"layui-form-label\">分数范围</label>\n" +
            "            <div class=\"layui-input-inline\" style=\"width: 100px;\">\n" +
            "                <input type=\"number\" name=\"price["+s_id+"][min]\" lay-field=\"price_min[]\" placeholder=\"分数\" autocomplete=\"off\" class=\"layui-input\">\n" +
            "            </div>\n" +
            "            <div class=\"layui-form-mid\">-</div>\n" +
            "            <div class=\"layui-input-inline\" style=\"width: 100px;\">\n" +
            "                <input type=\"number\" name=\"price["+s_id+"][max]\" lay-field=\"price_max[]\" placeholder=\"分数\" autocomplete=\"off\" class=\"layui-input\">\n" +
            "            </div>\n" +
            "            <div class=\"layui-input-inline\" style=\"width: 100px;\">\n" +
            "                <button class=\"layui-btn\" onclick=\"$('#"+s_id+"').remove();\">\n" +
            "                    <i class=\"layui-icon\">&#xe640;</i> 删除\n" +
            "                </button>\n" +
            "            </div>\n" +
            "        </div>\n" +
            "\n" +
            "        <div class=\"layui-form-item layui-form-text\">\n" +
            "            <label class=\"layui-form-label\">评语</label>\n" +
            "            <div class=\"layui-input-block\">\n" +
            "                <textarea name=\"price["+s_id+"][comment]\" lay-field=\"comment[]\" placeholder=\"请输入内容\" class=\"layui-textarea\"></textarea>\n" +
            "            </div>\n" +
            "        </div>\n" +
            "        <hr>\n" +
            "    </div>"
        );
    }
</script>
</body>
</html>